/*
 PureMVC AS3 Demo - Flex Employee Admin 
 Copyright (c) 2007-08 Clifford Hall <clifford.hall@puremvc.org>
 Your reuse is governed by the Creative Commons Attribution 3.0 License
 */
package vn.demand.dragon
{
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.patterns.facade.Facade;
	
	import vn.demand.dragon.controller.CloseCustomerListCommand;
	import vn.demand.dragon.controller.CloseNewQuotationPanelCommand;
	import vn.demand.dragon.controller.CloseQuotationListCommand;
	import vn.demand.dragon.controller.CloseQuotationPanelCommand;
	import vn.demand.dragon.controller.CompanyAddedCommand;
	import vn.demand.dragon.controller.CompanyDeletedCommand;
	import vn.demand.dragon.controller.NewQuotationCommand;
	import vn.demand.dragon.controller.OpenCustomerFormCommand;
	import vn.demand.dragon.controller.OpenCustomerListCommand;
	import vn.demand.dragon.controller.OpenQuotationCommand;
	import vn.demand.dragon.controller.OpenQuotationListCommand;
	import vn.demand.dragon.controller.RemoveQuotationCommand;
	import vn.demand.dragon.controller.RequestLoginCommand;
	import vn.demand.dragon.controller.RequestLogoutCommand;
	import vn.demand.dragon.controller.StartupCommand;
	import vn.demand.dragon.controller.SupplierAddedCommand;
	
	public class MarketingApplicationFacade extends Facade implements IFacade
	{
		// Notification name constants
		public static const STARTUP:String 			= "startup";
	
		public static const QUOTATION_LINE_TO_CLIPBOARD:String 	= "QUOTATION_LINE_TO_CLIPBOARD";
		
		public static const LOAD_MASTERDATA_SUCCESS:String 	= "loadMasterdataSuccess";
		public static const LOAD_MASTERDATA_FAILED:String 	= "loadMasterdataFailed";
		
		public static const REFRESH_QUOTATION:String 	= "refreshQuotation";
		public static const SAVE_QUOTATION:String 	= "saveQuotation";
		public static const NEW_QUOTATION:String 	= "newQuotation";
		public static const DELETE_QUOTATION:String 	= "deleteQuotation";
		
		public static const QUOTATION_ACTIVATED:String 	= "quotationActivated";
		public static const QUOTATION_UN_ACTIVATED:String 	= "quotationUnActivated";
		public static const QUOTATION_COMPLETED:String 	= "quotationCompleted";
		public static const QUOTATION_ACTIVATE_FAILED:String 	= "quotationActivate_FAILED";
		public static const QUOTATION_UN_ACTIVATE_FAILED:String 	= "quotationUnActivate_FAILED";
		public static const QUOTATION_COMPLETE_FAILED:String 	= "quotationComplete_FAILED";
		public static const QUOTATION_SELECTED:String 	= "quotationSelected";
		public static const QUOTATION_UPDATED:String 	= "quotationUpdated";
		public static const QUOTATION_UPDATE_FAILED:String 	= "quotationUpdateFailed";
		public static const QUOTATION_ADDED:String 	= "quotationAdded";
		public static const LOAD_QUOTATION_SUCCESS:String 	= "loadQuotationSuccessful";
		public static const LOAD_QUOTATION_FAILED:String 	= "loadQuotationFailed";
		public static const BROWSE_QUOTATION_LIST:String 	= "browseQuotationList";
		public static const OPEN_QUOTATIONS_LIST:String 	= "openQuotationList";
		public static const CLOSE_QUOTATIONS_LIST:String 	= "closeQuotationList";
		public static const CLOSE_QUOTATION_PANEL:String 	= "CLOSE_QUOTATION_PANEL";
		public static const CLOSE_QUOTATION_HEADER:String 	= "CLOSE_QUOTATION_HEADER";
		public static const CLOSE_QUOTATION_LINES:String 	= "CLOSE_QUOTATION_LINES";
		public static const CLOSE_FINISH_QUOTATION_PANEL:String 	= "CLOSE_FINISH_QUOTATION_PANEL";
		public static const CLOSE_NEW_QUOTATION_PANEL:String 	= "CLOSE_NEW_QUOTATION_PANEL";
		
		
		public static const REFRESH_QUOTATION_LINES:String 	= "refreshQuotationLines";
		public static const DELETE_QITEM:String 	= "deleteQItem";
		public static const SAVE_QITEMS:String 	= "saveQItems";
		
		public static const LOAD_QUOTATION_DETAIL_SUCCESS:String 	= "loadQuotationDetailSuccess";
		public static const LOAD_QUOTATION_DETAIL_FAILED:String 	= "loadQuotationDetailFailed";
	
		public static const LOAD_QITEMS_LIST_SUCCESS:String 	= "loadQItemsListSuccess";
		public static const LOAD_QITEMS_LIST_FAILED:String 	= "loadQItemsListFailed";
		
		public static const QITEM_DELETED:String 	= "qitemDeleted";
		public static const QITEMS_UPDATED:String 	= "qitemsUpdated";		
		public static const QITEMS_UPDATE_FAILED:String 	= "qitemsUpdateFailed";		
		public static const QITEM_EDIT_END:String 	= "qitemEditEnd";
		public static const ADD_EMPTY_QITEM:String 	= "addEmptyQItem";
	
		public static const REFERENCE_SELECTED:String 	= "referenceSelected";
		
		public static const LOAD_TASKS_BY_REFERENCE_SUCCESS:String 	= "loadTasksByReferenceSuccess";
		public static const LOAD_TASKS_BY_REFERENCE_FAILED:String 	= "loadTasksByReferenceFailed";
		
		
		/**
		 * Singleton ApplicationFacade Factory Method
		 */
		public static function getInstance() : MarketingApplicationFacade {
			if ( instance == null ) instance = new MarketingApplicationFacade( );
			return instance as MarketingApplicationFacade;
		}
		
		/**
		 * Start the application
		 */
		 public function startup(app:Object):void
		 {
		 	//sendNotification( STARTUP, app );
		 	sendNotification( CommonCommand.REQUEST_LOGIN, app );
		 }

		/**
		 * Register Commands with the Controller 
		 */
		override protected function initializeController( ) : void 
		{
			super.initializeController();
			registerCommand( CommonCommand.REQUEST_LOGIN, RequestLoginCommand);
			registerCommand( CommonCommand.LOGIN_SUCCESSFUL, StartupCommand );
			registerCommand( OPEN_QUOTATIONS_LIST, OpenQuotationListCommand);
			registerCommand( CLOSE_QUOTATIONS_LIST, CloseQuotationListCommand);
			registerCommand( QUOTATION_SELECTED, OpenQuotationCommand);
			registerCommand( NEW_QUOTATION, NewQuotationCommand);
			registerCommand( DELETE_QUOTATION, RemoveQuotationCommand);
			registerCommand( CLOSE_FINISH_QUOTATION_PANEL, CloseQuotationPanelCommand);
			registerCommand( CLOSE_NEW_QUOTATION_PANEL, CloseNewQuotationPanelCommand);
			registerCommand( CommonCommand.CUSTOMERS_UPDATED_SUCESSFUL, CompanyAddedCommand);
			registerCommand( CommonCommand.SUPPLIER_ADDED, SupplierAddedCommand);
			registerCommand( CommonCommand.OPEN_COSTOMERS_LIST, OpenCustomerListCommand);
			registerCommand( CommonCommand.ADD_CUSTOMER, OpenCustomerFormCommand);
			registerCommand( CommonCommand.CUSTOMERS_SELECTED, OpenCustomerFormCommand);
			registerCommand( CommonCommand.DELETE_CUSTOMER_SUCCESSFUL, CompanyDeletedCommand);
			registerCommand( CommonCommand.CLOSE_CUSTOMERS_LIST, CloseCustomerListCommand);
			registerCommand( CommonCommand.REQUEST_LOGOUT, RequestLogoutCommand);
		}
		
	}
}